<?php
include("../safe.php");
function replace_specialChar($strParam){
    $regex = "/\/|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\'|\`|\-|\=|\\\|\|/";
    return preg_replace($regex,"",$strParam);
}
$width=replace_specialChar($_REQUEST["width"]);
$bname=$_GET["bname"];
$lang=$_GET["lang"];
?> 
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<title><?php echo $site_name;?>后台管理-产品图片管理</title>
<link href="../bootstrap/css/bootstrap.min.css" title="" rel="stylesheet" />
<link href="../css/mcommon.css" rel="stylesheet" title="" type="text/css" />
<link href="../css/style.css" rel="stylesheet" type="text/css"  />
<link rel="shortcut icon" href="/logo.ico" />
<script language="javascript">
<!--
function CheckAll(form)
{
  for (var i=0;i<form.elements.length;i++)
  {
  var e = form.elements[i];
  if (e.Name != "chkAll"&&e.disabled!=true)
  e.checked = form.chkAll.checked;
  }
}
//-->
</script>
</head>

<body>
<!--顶部-->
<?php include("../top.php");?> 
<!--顶部结束--->
<!--主体部分-->
<div class="down-main">
	<!--左侧部分-->
  <?php include("../left.php");?> 
  <!--左侧部分结束-->
  <!--右侧部分-->
  <div class="right-product right-full">
  	<!--右侧内容部分-->
    <div class="container-fluid right-product-con">
    	<div class="mianbaoxie"><i class="glyphicon-folder-open glyphicon"></i>
    		<span>管理中心</span>&gt;<span class="dangqian">产品图片管理</span></div>
      <div class="container-con">
      		<!--表格-->
      		<div class="tableCon">
			<div class="tableCon-tit clear">产品图片管理</div>
	      		<div class="tableCon-content">
				<table width="98%" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC" class="wenzi">
      <tr>
        <td height="20" colspan="5" bgcolor="#DEDEEF"><div align="left">
          <table width="350" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td><div align="right">图片宽度&lt; </div></td>
              <form action="imglist.php?bname=<?php echo $bname;?>&lang=<?php echo $lang;?>" method="post" name="form2" id="form2" class="form-inline">
                <td><div align="left">
                    <input name="width" type="number" id="width" class="form-control"/>
                </div></td>
                <td><div align="left">
                    <input type="submit" class="btn btn-success" value="查询"/>
                </div></td>
              </form>
            </tr>
          </table>
        </div></td>
      </tr>
	  <form id="form1" name="form1" method="post" action="del_save.php?action=del&lang=products">
      <tr>
        <td height="20" bgcolor="#FFFFFF"><div align="center">序号</div></td>
        <td bgcolor="#FFFFFF"><div align="left">图片</div></td>
        <td bgcolor="#FFFFFF"><div align="center">图片大小</div></td>
        <td bgcolor="#FFFFFF"><div align="left">所属产品</div></td>
        <td bgcolor="#FFFFFF"><div align="left">操作</div></td>
      </tr>
  <?php
  if(!empty($width)){
  if($_SESSION["thetype"]=="管理员"){$sql="select * from ph_".$lang." where 1=1 and bname='".$bname."'";}else{$sql="select * from ph_".$lang." where 1=1 and bname='".$bname."' and user_name='".$_SESSION["managername"]."'";}
$result=mysqli_query($conn,$sql);
  while($row=mysqli_fetch_array($result)){
    //echo $row[ID];
  $sqls="select * from ph_img where proid='".$row["ID"]."'";
  $results=mysqli_query($conn,$sqls);
  while($rows=mysqli_fetch_array($results)){
  $img_info = getimagesize("..".$rows["imgpath"]);
  
  if($img_info[0]<$width){
  ?>
      <tr>
        <td height="20" bgcolor="#F7F7F7"><div align="center">
          <input name="id[]" type="checkbox" id="id[]" value="<?php echo $row["ID"];?>" />
        </div></td>
        <td bgcolor="#F7F7F7"><div align="left"><img src="<?php echo $rows["imgpath"];?>" width="50" height="50" /></div></td>
        <td bgcolor="#F7F7F7"><div align="center"><?php echo $img_info[0];?> x <?php echo $img_info[1];?></div></td>
        <td bgcolor="#F7F7F7"><div align="left"><?php echo $row["proname"];?></div></td>
        <td bgcolor="#F7F7F7"><div align="left"><a class="btn btn-success" role="button" href="products_edit.php?id=<?php echo $row["ID"];?>&lang=products" target="_blank">编辑</a> <a class="btn btn-danger" role="button" href="del_save.php?action=del&id=<?php echo $row["ID"];?>&lang=products" target="_blank">删除</a></div></td>
      </tr>
  <?php }}}}?>
      <tr>
        <td bgcolor="#F7F7F7">&nbsp;</td>
        <td height="20" colspan="4" bgcolor="#F7F7F7"><div align="left">全选
          <input name="chkAll" type="checkbox" id="chkAll" onClick="CheckAll(this.form)" value="checkbox" /><input type="submit" class="btn btn-danger" value="删除选中"/>
        </div></td>
      </tr>
    </form>
  </table>
	      		</div>
	      	</div>
	      	<!--表格结束--->
      	</div>
      </div>
  </div>
	  <!--右侧内容部分结束-->
  </div>
  <!--右侧部分结束-->
</div>
<!--主体部分结束-->
<script src="../js/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="../bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="../js/mcommon.js"></script>
</body>
</html>
